--package.path = "./?/init.lua;./dependencies/?.lua;."..package.path

-- Install Sputnik into $SPUTNIK_DIR
SPUTNIK_DIR = "/home/yuri/tmp/sputnik-2007-11-21d"
WIKI_DATA_DIR = SPUTNIK_DIR.."/wiki-data/"

package.path  = package.path..";"..SPUTNIK_DIR.."/share/lua/5.1/?.lua"
                            ..";"..SPUTNIK_DIR.."/share/lua/5.1/?/init.lua"
package.cpath = package.cpath..";"..SPUTNIK_DIR.."/lib/lua/5.1/?.so"

debug = function() 
   -- do nothing
end

require("sputnik")
--require("sputnik.config")  -- we won't be using the config file

cookie = nil -- this is a global to store the cookie

function write(text)
   print(text)
end

config = {
   WIKI_DATA_DIR    = WIKI_DATA_DIR,
   BASE_URL         = "sputnik.cgi",
   SCRIPT_PATH      = "xxx",
   SECRET_CODE      = "093418239874981732",
   CONFIG_PAGE_NAME = "_config",
   PASS_PAGE_NAME   = "_passwords"
}

function call_sputnik_without_kepler(params)
   local request  = {}
   local response = {}
   request.get_cookie = function (cookie_name)
      return cookie -- let's just use a global to store the cookie, ignore the cookie_name
   end
   request.params = params

   response.set_cookie = function(cookie_name, cookie_value)
      cookie = cookie_value
   end
   response.set_content_type = function(content_type)
      write("Content-Type: "..content_type)
   end
   response.write = function (text)
      write(text) 
   end
   
   mySputnik = sputnik.Sputnik:new(config)
   mySputnik:run(request, response)
end

print()
--call_sputnik_without_kepler{}  -- get the home page
call_sputnik_without_kepler{p="Sandbox.edit"}
		




